#include "unzip.h"
#include "zip.h"
#include "ZipPortal.h"
#include <string>
using namespace std;
void UnZipArchive(const wchar_t* zipArchivePath, const wchar_t* outPath) {
    HZIP hz = OpenZip(zipArchivePath, NULL);
    ZIPENTRY ze;
    GetZipItem(hz, -1, &ze);
    int numitems = ze.index;
    for (int zi = 0; zi < numitems; zi++)
    {
        ZIPENTRY ze;
        GetZipItem(hz, zi, &ze);
        char* ibuf = new char[ze.unc_size];
        UnzipItem(hz, zi, ibuf, ze.unc_size);
        wstring path(outPath);
        path.append(L"\\").append(ze.name);
        if (path[path.length() - 1] == L'\\' || path[path.length() - 1] == L'/') {
            path = path.substr(0, path.length() - 1);
            CreateDirectory(path.c_str(),NULL);
            continue;
        }
        FILE* fout = _wfopen(path.c_str(), L"w+b");
        fwrite(ibuf, 1, ze.unc_size, fout);
        fclose(fout);
        //UnzipItem(hz, zi, ze.name);
    }
    CloseZip(hz);
}